/* Laboratorio # 2 - Administración de bases de datos
 Jorge Fallas Ramos         402090469
 José Roberto Sánchez       115400070
 Daniel Villalobos Venegas  402110100
 */
package monitorinitdb;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import monitorinitdb.Vista.ConsolaSalida;

public abstract class ConectorOracle {

    String user, pass;
    Runtime run;

    public ConectorOracle(String user, String pass) {
        this.user = user;
        this.pass = pass;
        this.run = Runtime.getRuntime();
    }

    abstract public void ejecutaInstruccion(String script);

    public String getUser() {
        return user;
    }

    public void setUser(String user) {
        this.user = user;
    }

    public String getPass() {
        return pass;
    }

    public void setPass(String pass) {
        this.pass = pass;
    }

    public Runtime getRun() {
        return run;
    }

    public void setRun(Runtime run) {
        this.run = run;
    }

    public void muestraConsola(InputStream input) {
        try {
            ConsolaSalida.io.setTitle("Ejecucion ORACLE");
            InputStreamReader lector = new InputStreamReader(input);
            BufferedReader l = new BufferedReader(lector);
            String linea = null;
            while ((linea = l.readLine()) != null) {
                ConsolaSalida.io.println(linea);
            }
            lector.close();
        } catch (IOException ex) {
            ConsolaSalida.io.println(ex.getMessage());
        }
    }
}
